<template>
  <div></div>
</template>

<script>
import order from "../../api/order";
export default {
  mounted() {
    order.buy(this.$route.params.id).then((resp) => {
      let divForm = document.getElementsByTagName("divform");
      if (divForm.length) {
        document.body.removeChild(divForm[0]);
      }
      const div = document.createElement("divform");
      div.innerHTML = resp.data.item; // res.data就是sb支付宝返回给你的form
      console.log(resp.data.item);
      document.body.appendChild(div);
      // document.forms[0].setAttribute('target', '_blank') // 加了_blank可能出问题所以我注释了
      document.getElementById("alipay_submit").submit();
    });
  },
  methods: {
    order,
  },
};
</script>

<style></style>
